DATA SEGMENT
    MESS  DB 'Triangle',0DH,0AH,'$'    ;三角形
    MESS1 DB '(0,0)',0DH,0AH,'$'
    MESS2 DB '(0,100)',0DH,0AH,'$'
    MESS3 DB '(100,0)',0DH,0AH,'$'     ;坐标
    F_AL  DB ?
DATA ENDS
CODE SEGMENT
          ASSUME CS:CODE,DS:DATA
START:    MOV AX,DATA
          MOV    DS,AX
          MOV    AH,0FH
          INT    10H
          MOV    BYTE PTR [F_AL],AL    ;保存原始显示模式
          MOV    AH,0
          MOV    AL,04
          INT    10H                   ;设置图形模式
          MOV    DX,60
          MOV    CX,100
    DONE1:MOV    AH, 0CH
          MOV    AL,02
          INT    10H                   ;画直角三角形的斜边
          INC    CX
          INC    DX
          CMP    DX,140
          JNZ    DONE1
          MOV    DX,140
          MOV    CX,180
    DONE2:MOV    AH, 0CH
          MOV    AL,02
          INT    10H                   ; 画直角三角形的一个直角边
          DEC    CX
          CMP    CX,99
          JNZ    DONE2
          MOV    DX,60
          MOV    CX,100
    DONE3:MOV    AH,0CH
          MOV    AL,02
          INT    10H                   ; 画直角三角形的另一个直角边

          INC    DX
          CMP    DX, 140
          JNZ    DONE3
          MOV    AH,02
          MOV    DH,19
          MOV    DL,13
          INT    10H
          MOV    BP,OFFSET MESS
          MOV    CX,8
    LOP:  MOV    AH,0EH
          MOV    AL,[BP]
          INC    BP
          MOV    BL,3
          INT    10H                   ;显示”Triangle”
          LOOP   LOP
          MOV    DH,17
          MOV    DL,7
          MOV    BX, OFFSET MESS1
          CALL   DISP
          MOV    DH,7
          MOV    DL,5
          MOV    BX,OFFSET MESS2
          CALL   DISP
          MOV    DH,17
          MOV    DL,23
          MOV    BX,OFFSET MESS3
          CALL   DISP
    LOP1: MOV    AH,06H
          MOV    DL,0FFH
          INT    21H                   ;是否有键按下?
          JNZ    OVER
          JMP    LOP1
    OVER: MOV    AH,0
          MOV    AL,BYTE PTR[F_AL]
          INT    10H                   ;恢复原始显示模式
          MOV    AX,4C00H
          INT    21H                   ;返回 DOS
DISP PROC NEAR
          MOV    AH,02H
          INT    10H

          MOV    AH,09H
          MOV    DX,BX
          INT    21H                   ;显示坐标值
          RET 
DISP ENDP
CODE ENDS
END START
